#ifndef GAINWIDGET_H
#define GAINWIDGET_H


#include "adaptivewidgets.h"
#include "peakbar.h"

class GainWidget : public AGroupBox
{
    Q_OBJECT
public:
    explicit GainWidget(const uint8_t &channel, const double &max, QWidget *parent = nullptr);

signals:
    void speakerChanged(uint8_t, uint8_t);
    void phaseChanged(uint8_t, uint8_t);
    void gainChanged(uint8_t, uint16_t);
public slots:
    void set(uint16_t gain, uint8_t speaker, uint8_t phase);
    void peak(const uint8_t &value);
private slots:
    void sliderChanged(const int &value);
    void spinBoxChanged(const double &value);
    void speakerToggled(bool checked);
    void phaseToggled(bool checked);
private:
    void setBlockSignals(bool block);
private:
    const uint8_t m_channel;
    PeakBar *bar;
    ASlider *slider;
    ADoubleSpinBox *spinBox;
    APushButton *speakerButton;
    APushButton *phaseButton;
};

#endif // GAINWIDGET_H
